<?php
/**
 * 用户流水表
 */
namespace app\admin\model;
use app\common\model\UserMoneyLog as UserMoneyLogModel;
use app\admin\model\Member as MemberModel;
class UserMoneyLog extends UserMoneyLogModel
{
    /**
     * 获取用户资金流水
     * @param array $where
     * @param int $page
     * @param int $limit
     * @param string $order
     * @return array
     * @throws \think\db\exception\DbException
     */
    public static function getList($where=[],$page=1,$limit=20,$order = 'id desc'){
        $data = self::where($where)->order($order)->paginate(['list_rows'=>$limit,'page'=>$page])->toArray();
        //翻译来源
        foreach ($data['data'] as $k => $v){
            $data['data'][$k]['username'] = MemberModel::getDetails($v['mid'])['username'];
            $data['data'][$k]['type_name'] = config('capital')[$v['type']]['simplified'];
        }
        return $data;
    }

    /**
     * 获取用户资金流水
     * @param array $where
     * @param int $page
     * @param int $limit
     * @param string $order
     * @return array
     * @throws \think\db\exception\DbException
     */
    public static function getAll($where=[],$order = 'id desc'){
        $data = self::where($where)->order($order)->select()->toArray();
        //翻译来源
        foreach ($data as $k => $v){
            $data[$k]['type_name'] = config('capital')[$v['type']]['simplified'];
        }
        return $data;
    }
}